<?php $this->load->module('mobile/index/header', $common);?>
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/main.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/dialog.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/base.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/index.css" />
<link rel="stylesheet" type="text/css" href="<?php echo URLPRE;?>static/template/default/mobile/css/line.css" />
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/mobilecommon.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/slider.js"></script>
<script type="text/javascript" src="<?php echo URLPRE;?>static/template/default/mobile/js/dialog.js"></script>
<style type="text/css">
    .list-item .info h5{text-overflow:clip;white-space:normal;padding-top:3px;line-height: normal}
    .foodlist li{float:left;width:50%}
    .food-left{width:92%;margin:10px 2%;}
    .food h1{
        font-size: 1rem;
        color: #349cd1;
        height: 1.3rem;
        overflow: hidden;
    }.food span {
         font-size: 0.5rem;
         color: #9e9e9e;
         height: 1.5rem;
         overflow: hidden;
         display: block;
     }
    .food-picture, .car-picture{
        height:120px;
    }
</style>
<div class="wrap" >
    <div class="container">
        <div class="blank5"></div>
        <div class="jdsearch">
            <form action="" method="post" id="searchForm" onsubmit="return sech();">
                <input type="text" id="search_name" placeholder="输入城市/店名/美食..." >
            </form>
        </div>
        <!--搜索-->
        <!-- 美食-->
        <ul class="foodlist">
            <?php if(DEBUG){print_r($datalist);}
            foreach ($datalist as $v) { ?>
            <li>
                <div class="food">
                    <div class="food-left" >
                        <a href="<?php echo $v['link']?>"><div  class="food-left1" >
                                <img class="food-picture" src="<?php echo $v['file_url'];?>" onerror="this.error=null;this.src='<?php echo URLPRE;?>static/public/images/nophoto.jpg'">
                                <h1><?php echo $v['subject'];?></h1>
                                <span><?php echo $v['keywords']?></span>
                            </div></a>
                    </div>
                </div>
            </li>
            <?php }?>
        </ul>
    </div>
</div>
<a href="javascript:;" class="btn-grey btn">加载更多</a>

<?php $this->load->module('mobile/index/footer', $common);?>
<script type="text/javascript">

    var url = '<?php echo site_url('mobile/trips/index/?category='.$_GET['category']);?>';
    function sech () {
        keyword = $('#search_name').val();
        if(keyword.length> 0){
            keyword = encodeURIComponent(keyword);
            window.location.href = url+(url.indexOf("?") > -1 ? "&" : "?")+'keyword='+keyword;
        }
        return false;
    }
    $(function(){
        var slid = $("#sliderimg").slider({
            loop: true
        });
        var page = <?php echo $page+1;?>;
        var keyword = '<?php echo $keyword?>';
        var url = '<?php echo site_url('mobile/trips/index');?>';
        $('.btn-grey').click(function(){
            var $this = $(this);
            $this.text('加载中...');
            $.get(url+(url.indexOf('?')!=-1 ?'&':'/?')+'isajax=1&keyword='+keyword+'&page='+page+'&category=<?php echo $_GET['category'];?>', function(data){
                if(data.length>0){
                    var html = '';
                    for(var i =0; i<data.length; i++){
                        var item = data[i];
                        html += '<li><div class="food"><div class="food-left" ><a href="'+ item.link +'"><div  class="food-left1" >' +
                        '<img class="food-picture" src="'+ item.file_url +'">' +
                        '<h1>'+ item.subject +'</h1>' +
                        '<span>'+ item.keywords +'</span>' +
                        '</div></a></div></div></li>';
                    }
                    $('.foodlist').append(html);
                    page ++;
                }else{
                    $.dialog({
                        style:'tip',
                        width:200,
                        closeTime:1000,
                        content: '<p style="text-align: center">没有更多了</p>'
                    }).open();
                }
                $this.text('加载更多');
            },'json');
        });
    });
</script>